package com.cat.yygh.user.controller.admin;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cat.yygh.common.result.R;
import com.cat.yygh.model.user.UserInfo;
import com.cat.yygh.user.service.UserInfoService;
import com.cat.yygh.vo.user.UserInfoQueryVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/administrator/userinfo")
public class AdminInfoController {
    @Autowired
    private UserInfoService userInfoService;
    //用户列表（条件查询带分页）
    @GetMapping("{page}/{limit}")
    public R list(@PathVariable long page,
                  @PathVariable long limit,
                  UserInfoQueryVo infoQueryVo){
        Page<UserInfo> userInfoPage = userInfoService.selectPage(page,limit,infoQueryVo);
        return R.ok().data("pageModel",userInfoPage);
    }

    @ApiOperation(value = "锁定")
    @PutMapping("lock/{userId}/{status}")
    public R lock(@PathVariable("userId") Long userId,
                  @PathVariable("status") Integer status){
        userInfoService.lock(userId,status);
     return R.ok();
    }
    @ApiOperation(value = "用户详情")
    @GetMapping("show/{userId}")
    public R show(@PathVariable("userId") Long id){
        userInfoService.show(id);
        Map<String,Object> map = userInfoService.show(id);
     return R.ok().data(map);
    }
    @ApiOperation(value = "认证审批")
    @GetMapping("approval/{userId}/{authStatus}")
    public R approval(@PathVariable("userId") Long userId,
                        @PathVariable("authStatus") Integer authStatus){
        userInfoService.approval(userId,authStatus);
        return R.ok();
    }
}
